//
//  TTMusicDiscoveryPageSecondCollectionViewCell.m
//  TTMusic
//
//  Created by chenpengyu on 16/3/31.
//  Copyright © 2016年 cpy. All rights reserved.
//

#import "TTMusicDiscoveryPageSecondCollectionViewCell.h"
@implementation TTMusicDiscoveryPageSecondCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.typeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(38, 16, 32, 32)];
        [self updateFrame:_typeImageView];
        self.typeLabel = [[TTMusicBaseLabel alloc] initWithFrame:CGRectMake(0, 50 * FitWidth, self.bounds.size.width, 20 * FitWidth)];
        _typeLabel.textAlignment = NSTextAlignmentCenter;
//        [_typeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.mas_equalTo(self.contentView.mas_top).offset(16);
//            make.left.mas_equalTo(self.contentView.mas_left).offset(38);
//            make.width.mas_equalTo(self.contentView.mas_width).offset(76);
//            make.height.mas_equalTo(self.contentView.mas_width).offset(76);
//        }];
////        [_typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
////            make.top.mas_equalTo(_typeImageView.mas_bottom).offset(5);
////            make.left.mas_equalTo(self.contentView).offset(38);
//////            make.width.equalTo(_typeImageView.mas_width);
////        }];
        [self updateFrame:_typeLabel];
        [self.contentView addSubview:_typeImageView];
        [self.contentView addSubview:_typeLabel];
    }
    return self;
}
- (void)updateFrame:(UIView *)view{
    
    CGRect rect = view.frame;
    view.frame = CGRectMake(rect.origin.x * FitWidth, rect.origin.y * FitWidth, rect.size.width * FitWidth, rect.size.height * FitWidth);
}

- (void)setDataDetailModel:(CPYDiscoveryPageDataDetailModel *)dataDetailModel  {
    [_typeImageView sd_setImageWithURL:[NSURL URLWithString:dataDetailModel.picUrl]];
    _typeLabel.text = dataDetailModel.name;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
